package com.special.threademo.concurrency.deadThread;

import com.special.threademo.concurrency.synchcriozed.MyThreadTest;

/**
 * Created with IDEA2020.3
 * author:LiuYC
 * DateTime:2021/1/15  10:00
 */
public class deadTest {
    private Object lock1 = new Object();
    private Object lock2 = new Object();

    public void myMethod1() {
        synchronized (lock1) {
            synchronized (lock2) {
                System.out.println("mymythod1 invoked");
            }

        }

    }

    public void myMethod2() {
        synchronized (lock1) {
            synchronized (lock2) {
                System.out.println("mymythod1 invoked");
            }

        }

    }

    public static void main(String[] args) {
        deadTest deadTest = new deadTest();
        Runnable runnable = () -> {
            while (true) {
                deadTest.myMethod1();
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        Runnable runnable2 = () -> {
            while (true) {
                deadTest.myMethod2();
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
    }
}
